package com.lan.model.symbol;

import com.lan.model.Symbol;
import com.lan.model.Type;
import org.antlr.v4.runtime.ParserRuleContext;

public class Variable extends Symbol {
    //变量类型
    protected Type type = null;

    //// 作为parameter的变量的属性
    //缺省值
    protected Object defaultValue = null;

    public Variable(String name, Scope scope, String id, ParserRuleContext ctx) {
        this.name = name;
        this.scope = scope;
        this.id = id;
        this.ctx = ctx;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
    }

    /**
     * 是不是类的属性
     *
     * @return
     */
    public boolean isClassMember() {
        return scope instanceof Clazz;
    }


    @Override
    public String toString() {
        return "Variable " + name + " -> " + type;
    }

}